<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>预约过程 - 五四宪法历史资料陈列室</title>
    <link rel="stylesheet" href="/static/pc/css/style.css">
    <link rel="stylesheet" href="/static/layui/layui/css/layui.css"  media="all">
    <script src="/static/pc/js/jquery.min.js"></script>
    <script src="/static/js/common.js"></script>
    <script src="/static/layui/layui/layui.all.js"></script>
<!--    <script src="static/pc/js/ajaxbao.js"></script>-->
    <style>
        .aInfo{
            float: right;
            padding: 10px;
            margin-right: 30px;
            color: coral;
            font-size: 0.8em;
        }
    </style>
</head>
<body>
<div class="head">
    <img src="/static/pc/img/head.jpg" alt="">
</div>
<div class="main">

    <div class="title_img"><img src="/static/pc/img/zg.png" alt=""></div>
    <div class="top_right">
        {if condition="$Think.session.mobile"}<span class="login_status">{$Think.session.mobile} </span><a class="login_status" href="home_tuichu" onclick="$('.layer2').show()"> 退出</a>{/if}
        <a class="back" href="javascript:history.back(-1)">返回</a>
    </div>
    <form action="information" id="information" method="post">
        <input name="mobile" class="long" type="hidden" value="{$Think.session.mobile}">
        <div class="content information">
            <div class="prev_part">
                <div class="w53 order_type">
                    <span>预约类型 </span>
                    <a href="javascript:;" class="venue select ge" onclick="window.location.reload()" data-v="个人" ><img src="/static/pc/img/button.png" alt="">个人</a>
                    <a href="javascript:;" class="venue tu" data-v="团队"><img src="/static/pc/img/button1.png" alt="">团队</a>
                    <input type="hidden" value="0" name="type" class="type1">
                </div>
                <div class="personal">
                    <span>政治面貌</span>
                    <select name="department" class="">
                        <option value=" ">---请选择---</option>
                        <option value="群众">群众</option>
                        <option value="党员">党员</option>
                        <option value="团员">团员</option>
                        <option value="民主党派人士">民主党派人士</option>
                    </select>
                </div>
                <div>
                    <span>联系人</span><input class="contact_name check" name="name" type="text" placeholder="请输入联系人姓名" title="联系人">
                </div>
                <div>
                    <span>国籍 </span><input name="nationality" type="text" value="中国" onkeyup="isChina(this)" placeholder="非中国籍请输入国籍及详细地址" title="国籍">
                </div>
                <div class="address">
                    <span>地区 </span>
                    <select name="province" class="province fl">
                        {foreach $province as $k=>$v}
                            {if $k eq 933}
                            <option value="{$k}" selected>{$v}</option>
                            {else/}
                            <option value="{$k}">{$v}</option>
                            {/if}
                        {/foreach}
                    </select>
                    <div class="city1 fl">
                        <select name="city_id" class="city">
                            {foreach $city as $k=>$v}
                            {if $k eq 934}
                            <option value="{$k}" selected>{$v}</option>
                            {else/}
                            <option value="{$k}">{$v}</option>
                            {/if}
                            {/foreach}
                        </select>
                    </div>
                    <div class="country1 fl" style="display: none">
                        <select name="country_id" class="country">
                        </select>
                    </div>
                </div>
                <p class="clear"></p>
                <a href="javascript:;" class="to_next"><img src="/static/pc/img/xyb.png" alt=""></a>  <!--下一步按钮-->
            </div>
            <div class="next_part">
                <div class="w53 company" style="display: none">
                    <span>单位名称 </span><input name="company" class="long" type="text" value="" placeholder="请输入单位名称" title="单位名称">
                </div>
                <div class="w47 company" style="display: none">
                    <span>单位类型</span>
                    <select name="position_type" id="position_type">
                        <option value = "">请选择单位类型</option>
                        {foreach $position_type as $k=>$v}
                        <option value="{$v}">{$v}</option>
                        {/foreach}
                    </select>
                </div>
                <div class="mb0">
                    <span>参观场馆</span>
                    <a href="javascript:;" class="venue first select"  data-v="A" ><img src="/static/pc/img/button.png" alt="">北山街馆区</a>
                    <a href="javascript:;" class="venue second" data-v="B"><img src="/static/pc/img/button1.png" alt="">栖霞岭馆区</a>
                    <a href="javascript:;" class="venue third" data-v="C" style="width: 30%"><img src="/static/pc/img/button1.png" alt="">北山街和栖霞岭馆区</a>
                    <input class="guan venuex"  name="venue" type="hidden" value="A">
                </div>
                <div class="visitor_num">
                    <span>参观人数</span><input name="views" type="text" data-max="100" class="number cgr" placeholder="请输入人数" onkeyup="visitorNum(this.value)" onblur="visitorNum1(this.value)" title="参观人数">
                </div>
                <div class="w53 explain">
                    <span>是否讲解</span>
                    <select name="explain" class="explain explain1" onchange="changejj(this.value)">
                        <option value="1">是</option>
                        <option value="0" selected>否</option>
                    </select>
                </div>
                <div class="timeLabel">
                    <span>参观时间</span>
                    <div class="guan_time">北山街馆区</div>
                    <input type="text" AUTOCOMPLETE="off" name="day" class="cday timeday check" id="dateBox" value="{$time[0]}" placeholder="选择参观日期" title="参观时间" style="margin-right: 30px">
                    <p class="aInfo">北山街馆区内提供自动语音讲解服务，馆内扫码讲解 </p> <span class="bguan_span"></span>
                </div>

                <div class="timeList">
                    <span class="arrive-time"></span>
                    <div class="timePart">
                        <span></span>
                        <a href="javascript:;" class="venue morninga select">上午</a>
                        <p class="clear"></p>
                        <span></span>
                        <a href="javascript:;" class="venue afternoona">下午</a>
                    </div>
                    <div class="arriveTime">
                        <span>时</span>
                        <select name="" id="visithour_a">
                            <option value="9">9</option>
                            <option value="10">10</option>
                            <option value="11">11</option>
                        </select>
                        <span>分</span>
                        <select name="" id="visitminute_a" style="margin-bottom: 30px">
                            <option value="00">00</option>
                            <option value="15">15</option>
                            <option value="30">30</option>
                            <option value="45">45</option>
                        </select><br>
                        <span>时</span>
                        <select name="" id="visithour_p">
                            <option value="14">14</option>
                            <option value="15">15</option>
                            <option value="16">16</option>
                        </select>
                        <span>分</span>
                        <select name="" id="visitminute_p">
                            <option value="00">00</option>
                            <option value="15">15</option>
                            <option value="30">30</option>
                            <option value="45">45</option>
                        </select>
                        <input type="hidden" name="arrivea_part" class="arrivea_part">
                        <input type="hidden" name="arrivea" class="arrivea">
                    </div>
                    <div class="aguan">
                        <p>
                            {foreach $visit_time2 as $k=>$v}
                            <a href="javascript:;" {if condition="in_array($k,$yuyue)"} class="booked" {/if} onclick="setValue({$k})"> {$v}</a>
                            {/foreach}
                            <input class="time check" name="time" type="hidden" title="时间段">
                        </p>
                    </div>
                    <!--<span></span>
                    <input type="text" placeholder="请输入预计到达时间，如9:00" class="arrive">-->
                </div>
                <div class="bguan">
                    <div class="guan_time">栖霞岭馆区</div>
                    <span></span>
                    <input type="text" AUTOCOMPLETE="off" name="day1" class="bday timeday1 guan_time" id="dateBox1" value="{$time[0]}" placeholder="选择参观日期" title="参观时间" >
                    <span class="arrive-time"></span>
                    <div class="timePart">
                        <span></span>
                        <a href="javascript:;" class="venue morningb select">上午</a>
                        <div class="clear"></div>
                        <span></span>
                        <a href="javascript:;" class="venue afternoonb">下午</a>
                    </div>
                    <div class="arriveTimeb">
                        <span>时</span>
                        <select name="" id="Bvisithour_a">
                            <option value="9">9</option>
                            <option value="10">10</option>
                            <option value="11">11</option>
                        </select>
                        <span>分</span>
                        <select name="" id="Bvisitminute_a" style="margin-bottom: 30px">
                            <option value="00">00</option>
                            <option value="15">15</option>
                            <option value="30">30</option>
                            <option value="45">45</option>
                        </select><br>
                        <span>时</span>
                        <select name="" id="Bvisithour_p">
                            <option value="14">14</option>
                            <option value="15">15</option>
                            <option value="16">16</option>
                        </select>
                        <span>分</span>
                        <select name="" id="Bvisitminute_p">
                            <option value="00">00</option>
                            <option value="15">15</option>
                            <option value="30">30</option>
                            <option value="45">45</option>
                        </select>
                        <input type="hidden" name="arriveb" class="arriveb">
                        <input type="hidden" name="arriveb_part" class="arriveb_part">
                    </div>
                    <div class="timeList1">
                        <p>
                            {foreach $visit_time2 as $k=>$v}
                            <a href="javascript:;" onclick="setValue({$k})">{$v}</a>
                            {/foreach}
                        </p>
                    </div>
                    <!--<span></span>
                    <input type="text" placeholder="请输入预计到达时间，如9:00" class="arrive">-->
                </div>
                <div>
                    <span>联系电话</span><input name="mobile" type="text" class="telephone check" onkeyup="checkMobile($(this).val())" placeholder="请输入联系电话" title="联系电话">
                </div>
                <div class="codezong">
                    <span>输入验证码</span><input name="code" class="check" type="text" placeholder="请输入验证码" title="验证码">
                    <a class="send" href="javascript:;">获取验证码</a>
                </div>
                <input type="hidden" name="status" value="1">
                <p class="clear"></p>
                <div class="button">
                    <a href="javascript:;" class="to_prev"><img src="/static/pc/img/syb.png" alt=""></a>
                    <a href="javascript:;" class="submit" onclick="checkParse()"><img src="/static/pc/img/check1.png" alt=""></a>
                </div>
            </div>
        </div>
        <input type="text" name="ctime" class="ctime" style="display: none">
    </form>
</div>
<script>
    function setSpecialDate(){
        $.ajax({
            type: 'GET',
            url: '/getDate',
            success: function (result) {
                var conNotV = result.conNotView;
                var conV = result.canVIew;
                var dataEm = $(".layui-laydate-content table tr td");
                $.each(dataEm,function(key,item){
                    if(!($.inArray(item.getAttribute('lay-ymd'), conV) == -1)){
                        item.setAttribute('class','');
                    }
                    if(!($.inArray(item.getAttribute('lay-ymd'), conNotV) == -1)){
                        item.setAttribute('class','laydate-disabled');
                    }
                })
            },
            error: function(result){
            },
        });
    }

    function setDefaultForbiddenDate(){
        $(".layui-laydate-content table tr td:nth-child(2)").addClass('laydate-disabled');
        if($(".explain1").val() ==1 ){
            $(".layui-laydate-content table tr td:nth-child(7)").addClass('laydate-disabled');
            $(".layui-laydate-content table tr td:nth-child(1)").addClass('laydate-disabled');
        }
    }

    layui.use('laydate', function(){
        var laydate = layui.laydate;
        //执行一个laydate实例
        laydate.render({
            elem: '#dateBox', //指定元素
            min: 0,
            max: 60,
            ready: function() {
                setDefaultForbiddenDate()
                setSpecialDate()
            },
            change: function() {
                setDefaultForbiddenDate()
                setSpecialDate()
            },
            done: function(value, date, endDate){
                $(".cday").val(value);
                var venue = $(".mb0 .select").attr("data-v");
                var day = $(".cday").val();
                var day1 = $(".bday").val();
                $.ajax({
                    type: 'POST',
                    url: 'runimformation',
                    data: {"day":day,"venue":venue,"day1":day1,'explain':$(".explain1").val()},
                    dataType:'json',
                    success: function (result) {
                        $(".aguan p").find("a").remove();
                        // $(".bguan").find("p").remove();
                        // if (result.yuyue){
                        if(result.explain == 1){
                            if(result.yuyueb){
                                if(result.yuyueb == ""){
                                    // return ;
                                }
                                if(result.yuyueb == "0"){
                                    alert(result.venue1+"上午的预约人数已满");
                                    // return ;
                                }
                                if(result.yuyueb == "1"){
                                    alert(result.venue1+"下午的预约人数已满");
                                    // return ;
                                }
                                if(result.yuyueb == "0,1"){
                                    alert(result.venue1+"当日预约人数已满");
                                    // return ;
                                }
                            }
                            if(result.yuyue == ""){
                                return ;
                            }
                            if(result.yuyue == "0"){
                                alert(result.venue+"上午的预约人数已满");
                                return ;
                            }
                            if(result.yuyue == "1"){
                                alert(result.venue+"下午的预约人数已满");
                                return ;
                            }
                            if(result.yuyue == "0,1"){
                                alert(result.venue+"当日预约人数已满");
                                return ;
                            }
                        }else{
                                var arr=JSON.stringify(result.yuyue);
                                var cc=JSON.parse(arr);
                                $.each(result.visit,function(i,val){
                                    if($.inArray( i, cc )==-1){
                                        $(".aguan p").append(
                                            '<a href="javascript:;" onclick="setValue()" >' +
                                            val+ "</a>")
                                    }else{
                                        $(".aguan p").append(
                                            '<a href="javascript:;" class="booked" onclick="setValue()" >' +
                                            val+ "</a>")
                                    }
                                });
                            }
                        // }
                    },
                    error: function(result){
                    },
                });
            },
        });
    });
    layui.use('laydate', function(){
        var laydate = layui.laydate;
        //执行一个laydate实例
        laydate.render({
            elem: '#dateBox1', //指定元素
            min: 0,
            max: 60,
            ready: function() {
                setDefaultForbiddenDate()
                setSpecialDate();
            },
            change: function() {
                setDefaultForbiddenDate()
                setSpecialDate();
            },
            done: function(value, date, endDate){
                $(".bday").val(value);
                var venue = $(".mb0 .select").attr("data-v");
                var day = $(".cday").val();
                // alert($(".bday").val());
                var day1 = $(".bday").val();
                $.ajax({
                    type: 'POST',
                    url: 'runimformation',
                    data: {"day":day,"venue":venue,"day1":day1,'explain':$(".explain1").val()},
                    dataType:'json',
                    success: function (result) {
                        $(".bguan p").find("a").remove();
                        // if (result.yuyue){
                            if(result.explain == 1){
                                if(result.yuyueb){
                                    if(result.yuyueb == ""){
                                        // return ;
                                    }
                                    if(result.yuyueb == "0"){
                                        alert(result.venue1+"上午的预约人数已满");
                                        // return ;
                                    }
                                    if(result.yuyueb == "1"){
                                        alert(result.venue1+"下午的预约人数已满");
                                        // return ;
                                    }
                                    if(result.yuyueb == "0,1"){
                                        alert(result.venue1+"当日预约人数已满");
                                        // return ;
                                    }
                                }
                                if(result.yuyue == ""){
                                    return ;
                                }
                                if(result.yuyue == "0"){
                                    alert(result.venue+"上午的预约人数已满");
                                    return ;
                                }
                                if(result.yuyue == "1"){
                                    alert(result.venue+"下午的预约人数已满");
                                    return ;
                                }
                                if(result.yuyue == "0,1"){
                                    alert(result.venue+"当日预约人数已满");
                                    return ;
                                }
                            }else{
                                if(result.yuyueb){
                                    $('.bguan_span').show();
                                    $(".bguan").css("display","block");
                                    $('.guan_time').show();
                                    $(".bguan").append(
                                        ' <input class="time1" name="time1" type="hidden">');
                                    var arr1=JSON.stringify(result.yuyueb);
                                    var cc1=JSON.parse(arr1);
                                    $.each(result.visit,function(i,val){
                                        if($.inArray( i, cc1 )==-1){
                                            $(".bguan p").append(
                                                '<a href="javascript:;" onclick="setValue1()" >' +
                                                val+ "</a>")
                                        }else{
                                            $(".bguan p").append(
                                                '<a href="javascript:;" class="booked"  onclick="setValue1()" >' +
                                                val+ "</a>")
                                        }
                                    })
                                }
                            }
                        // }
                    },
                    error: function(result){
                    },
                });
            },
        });
    });
    function changejj(obj){
        if(obj == 1){
            $('.aguan').hide()
            $('.timeList1').hide()
            $('.timePart').show()
            $('.arrive-time').text('预计到达')
            if($('.first').hasClass('select')){
                $('.timeList').show;
                $('.arriveTime').show()
                $('.bguan').hide()
            }
            if($('.second').hasClass('select')){
                $('.timeList').hide()
                $('.bguan').show()
                $('.arriveTimeb').show()
            }
            if($('.third').hasClass('select')){
                $('.arriveTime').show()
                $('.arriveTimeb').show()

            }
        }else{
            $('.aguan').show();
            $('.timeList').show()
            $('.arriveTime').hide()
            $('.arriveTimeb').hide()
            $('.timePart').hide()
            $('.arrive-time').text('')
        }
    }
    function isChina(obj){
        if($(obj).val()!="中国"){
            $(obj).siblings('span').html("国籍及地址");
            $('.address').hide();
            $('.province').attr('value','');
            $('.city1').attr('value','');
            $('.country1').attr('value','');
        }else{
            $(obj).siblings('span').html("国籍");
            $('.address').show()
        }
    }


    // function sendMobile(){
    //     var mobile = $(".telephone").val();
    //     $.ajax({
    //         type: 'POST',
    //         url: 'sendSNS',
    //         data: {"mobile":mobile},
    //         dataType:'json',
    //         success: function (result) {
    //             if(result == 1){
    //                 alert("发送成功");
    //             }
    //         },
    //     });
    // }
    /**
     * 点击下一步和上一步
     * */
    $('.to_next').click(function(){
        var department = $('.personal select').val();
        var contact_name = $('.contact_name').val();
        if($('.ge').hasClass('select')){
            $('.timeList ').show();
            $('.timeList1 ').show();
            if(department == " "){
                // alert("请选择政治面貌");
                layer.alert('请选择政治面貌',{
                    icon: 2,
                    title:false,
                    time:5000

                })
                return
            }if(!contact_name){
                // alert("请输入联系人");
                layer.alert('请输入联系人',{
                    icon: 2,
                    title:false,
                    time:5000

                })
                return
            }else{
                $('.next_part').show();
                $('.prev_part').hide();
            }
        }else{
            if(!contact_name){
                // alert("请输入联系人");
                layer.alert('请输入联系人',{
                    icon: 2,
                    title:false,
                    time:5000

                })
                return
            }else{
                $('.next_part').show();
                $('.prev_part').hide();
            }
        }
    });
    $('.to_prev').click(function(){
        $('.next_part').hide();
        $('.prev_part').show();
    });

    /**
     * 点击获得对应的时间值
     * */
    function setValue() {
        $('.timeList').on('click',"a",function(){
            if($(this).hasClass('booked')){
                return false;
            }
            if($(this).hasClass('booked1')){
                return false;
            }
            $(this).addClass('on').siblings().removeClass('on');
            $('.time').val($(this).html());
        })
    }
    function setValue1() {
        $('.timeList1').on('click',"a",function(){
            if($(this).hasClass('booked')){
                return false;
            }
            if($(this).hasClass('booked1')){
                return false;
            }
            $(this).addClass('on').siblings().removeClass('on');
            $('.time1').val($(this).html());
        })
    }

    function agree(obj){
        if($(obj).is(':checked')){
            $('.submit').attr('href','information.html').html('<img src="static/pc/img/woyaoyuyue.png" alt="">')
        }
        else{
            $('.submit').attr('href','javascript:;').html('<img src="static/pc/img/woyaoyuyue1.png" alt="">')
        }
    }


    /**
     * 选择馆加颜色
     * */
    $('.venue').click(function(){
        $(this).addClass('select').siblings().removeClass('select');
        $(this).find('img').attr('src','static/pc/img/button.png');
        $(this).siblings().find('img').attr('src','static/pc/img/button1.png');
        var guan = $(this).data('v');
        if(guan=="B"){
            $('.aInfo').text('');
        }else{
            $('.aInfo').text('北山街馆区内提供自动语音讲解服务，馆内扫码讲解');
        }
    });
    /**
     * 上来馆泽的框框
     * */
    $('.timeList a').click(function(){
        if($(this).hasClass('booked')){
            return false;
        }
        $(this).addClass('on').siblings().removeClass('on');
        $('input.time').val($(this).html());
    });


    function checkMobile(tel) {
        if(tel.length==11){
            var reg = /(^1[3|4|5|6|7|8|9][0-9]{9}$)/;
            if (reg.test(tel)) {
                $('.send').addClass('send_button');
                $(".send").attr("onclick","sendMobile(this);");
                return true;
            }else{
                layer.msg('手机号输入不正确',{icon:2,time:5000});
                return false;
            }
        }
    }

    var flag = false;
    function checkParse(event) {
        if($('.order_type .venue.select').attr('data-v') == "团队"){

            var long = $('input[name=company]').val();
            var views = $('input[name=views]').val();
            var position_type = $('#position_type option:selected') .val();
            // console.log(long)
            // console.log(position_type)
            if(long==''){
                // alert("请填写单位名称");
                layer.alert('请填写单位名称',{
                    icon: 2,
                    title:false,
                    time:5000
                })
                flag = false;
                event.preventDefault();
            }

            if(position_type==''){
                // alert("请选择单位类型");
                layer.alert('请选择单位类型',{
                    icon: 2,
                    title:false,
                    time:5000
                })
                flag = false;
                event.preventDefault();
            }
            if(views==''||views==0){
                // alert("请填写参观人数");
                layer.alert('请填写参观人数',{
                    icon: 2,
                    title:false,
                    time:5000
                })
                flag = false;
                event.preventDefault();
            }

        }

        if($('.explain1').val() == 1){
            if($('.mb0 .first').hasClass('select')){
                if($('.morninga').hasClass('select')){
                    var hour = $('#visithour_a').val();
                    var minute = $('#visitminute_a').val();
                    $('input.arrivea').val(hour + ":" + minute);
                    $('input.arrivea_part').val('上午')
                }else{
                    var hour = $('#visithour_p').val();
                    var minute = $('#visitminute_p').val();
                    $('input.arrivea').val(hour + ":" + minute)
                    $('input.arrivea_part').val('下午')
                }
            }
            if($('.mb0 .second').hasClass('select')){
                if($('.morningb').hasClass('select')){
                    var hour = $('#Bvisithour_a').val();
                    var minute = $('#Bvisitminute_a').val();
                    $('input.arriveb').val(hour + ":" + minute);
                    $('input.arriveb_part').val('上午')
                }else{
                    var hour = $('#Bvisithour_p').val();
                    var minute = $('#Bvisitminute_p').val();
                    $('input.arriveb').val(hour + ":" + minute)
                    $('input.arriveb_part').val('下午')
                }
            }
            if($('.mb0 .third').hasClass('select')){
                if($('.morninga').hasClass('select')){
                    var hour = $('#visithour_a').val();
                    var minute = $('#visitminute_a').val();
                    $('input.arrivea').val(hour + ":" + minute);
                    $('input.arrivea_part').val('上午')
                }
                if($('.afternoona').hasClass('select')){
                    var hour = $('#visithour_p').val();
                    var minute = $('#visitminute_p').val();
                    $('input.arrivea').val(hour + ":" + minute)
                    $('input.arrivea_part').val('下午')
                }
                if($('.morningb').hasClass('select')){
                    var hour = $('#Bvisithour_a').val();
                    var minute = $('#Bvisitminute_a').val();
                    $('input.arriveb').val(hour + ":" + minute);
                    $('input.arriveb_part').val('上午')

                }if($('.afternoonb').hasClass('select')){
                    var hour = $('#Bvisithour_p').val();
                    var minute = $('#Bvisitminute_p').val();
                    $('input.arriveb').val(hour + ":" + minute)
                    $('input.arriveb_part').val('下午')
                }
            }
        }
        $('.information input.check').each(function(){
            var text = $(this).val();
            if(text==""){
                if($('.explain1').val() == 1 && $(this).attr('title') == "时间段"){
                    $('.arrivea').val();
                    flag = true;
                }else{
                    // alert('请填写' + $(this).attr('title') + '!');
                    layer.alert('请填写' + $(this).attr('title') + '!',{
                        icon: 2,
                        title:false,
                        time:5000
                    })
                    flag = false;
                    event.preventDefault();
                }
            }
            else{
                flag = true;
            }
        });


        if(flag){
            $('#information').submit()
        }
    };
    $('.explain1').change(function(){
        $('.venue.select').click();
    });
    /**
     * 日期点击ajax循环添加
     * */
     $(".timeday").change(function(){
         var day = $(this).val();
         $(".timeday").val(day);
         $(".timeday1").val(day);
         var venue = $(".mb0 .select").attr("data-v");
         $.ajax({
             type: 'POST',
             url: 'runimformation',
             data: {"day":day,"venue":venue},
             dataType:'json',
             success: function (result) {
                 $(".timeList").find("a").remove();
                 $(".timeList1").find("a").remove();
                 // $('.bguan').hide();
                 $('.guan_time').hide();
                 $('.bguan_span').hide();
                 if (result.yuyue){
                     var arr=JSON.stringify(result.yuyue);
                     var cc=JSON.parse(arr);
                     $.each(result.visit,function(i,val){
                         if($.inArray( i, cc )==-1){
                             $(".timeList").find("p").append(
                                 '<a href="javascript:;" onclick="setValue()" >' +
                                 val+ "</a>")
                         }else{
                             $(".timeList").find("p").append(
                                 '<a href="javascript:;" class="booked" onclick="setValue()" >' +
                                 val+ "</a>")
                         }
                     });
                     if(result.yuyueb){
                         $('.bguan_span').show();
                         $(".bguan").show();
                         $('.guan_time').show();
                         $(".timeList1").find("p").append(
                             ' <input class="time1" name="time1" type="hidden">');
                         var arr1=JSON.stringify(result.yuyueb);
                         var cc1=JSON.parse(arr1);
                         $.each(result.visit,function(i,val){
                             if($.inArray( i, cc1 )==-1){
                                 $(".timeList1").find("p").append(
                                     '<a href="javascript:;" onclick="setValue1()" >' +
                                     val+ "</a>")
                             }else{
                                 $(".timeList1").find("p").append(
                                     '<a href="javascript:;" class="booked"  onclick="setValue1()" >' +
                                     val+ "</a>")
                             }
                         })
                     }
                 }else{
                     $.each(result.visit,function(i,val){
                         $(".timeList").find("p").append(
                             '<a href="javascript:;"  onclick="setValue()" >' +
                             val+ "</a>")
                     });
                 }
             },
             error: function(result){
                 // alert("21321");
             },
         });
     });

    /**
     * 馆项点击ajax循环添加
     * **/
    $('.mb0 a').click(function(){
        if($('.explain1').val() == 1){
            if($('.first').hasClass('select')){
                $('.timeList').show();
                $('.timeList .timePart').show();
                $('.timeLabel').show();
                $('.arriveTime').show();
                $('.bguan .timePart').hide();
                $('.bguan').hide();
                $('.arriveTimeb').hide();
            }
            if($('.second').hasClass('select')){
                $('.timeList .timePart').hide();
                $('.timeList').hide();
                $('.arriveTime').hide();
                $('.timeLabel').hide();
                $('.bguan').show();
                $('.bguan .timePart').show();
                $('.arriveTimeb').show();
            }
            if($('.third').hasClass('select')){
                $('.timeList .timePart').show();
                $('.timeList').show();
                $('.timeLabel').show();
                $('.arriveTime').show();
                $('.bguan').show();
                $('.bguan .timePart').show();
                $('.arriveTimeb').show();
            }
        }
        if($('.explain1').val() == 0){
            if($('.third').hasClass('select') || $('.second').hasClass('select')){
                $('.timeList1').show()
            }
            else{
                $('.timeList1').hide()
            }
        }
        var checkValue = $(".mb0 .select").attr("data-v");
        $(".venuex").val(checkValue);
        var day = $(".cday").val();
        var day1 = $(".bday").val();
        $.ajax({
            type: 'POST',
            url: 'runimformation',
            data: {"day":day,"venue":checkValue,"day1":day1,'explain':$(".explain1").val()},
            dataType:'json',
            success: function (result) {
                $(".aguan p").find("a").remove();
                $(".bguan p").find("a").remove();
                // $(".bguan").hide();
                $('.guan_time').hide();
                $('.bguan_span').hide();
                if(checkValue == "C"){
                    $('.guan_time').show();
                    $('.bguan_span').show();
                }
                // if (result.yuyue){
                    if(result.explain == 1){
                        if(result.yuyueb){
                            if(result.yuyueb == ""){
                                // return ;
                            }
                            if(result.yuyueb == "0"){
                                alert(result.venue1+"上午的预约人数已满");
                                // return ;
                            }
                            if(result.yuyueb == "1"){
                                alert(result.venue1+"下午的预约人数已满");
                                // return ;
                            }
                            if(result.yuyueb == "0,1"){
                                alert(result.venue1+"当日预约人数已满");
                                // return ;
                            }
                        }
                        if(result.yuyue == ""){
                            return ;
                        }
                        if(result.yuyue == "0"){
                            alert(result.venue+"上午的预约人数已满");
                            return ;
                        }
                        if(result.yuyue == "1"){
                            alert(result.venue+"下午的预约人数已满");
                            return ;
                        }
                        if(result.yuyue == "0,1"){
                            alert(result.venue+"当日预约人数已满");
                            return ;
                        }
                    }else{
                        var arr=JSON.stringify(result.yuyue);
                        var cc=JSON.parse(arr);
                        $.each(result.visit,function(i,val){
                            if($.inArray( i, cc )==-1){
                                $(".aguan p").append(
                                    '<a href="javascript:;" onclick="setValue()" >' +
                                    val+ "</a>")
                            }else{
                                $(".aguan p").append(
                                    '<a href="javascript:;" class="booked" onclick="setValue()" >' +
                                    val+ "</a>")
                            }
                        });
                        if(result.yuyueb){
                            $('.bguan_span').show();
                            $(".bguan").css("display","block");
                            $('.guan_time').show();
                            $(".bguan").append(
                                ' <input class="time1" name="time1" type="hidden">');
                            var arr1=JSON.stringify(result.yuyueb);
                            var cc1=JSON.parse(arr1);
                            $.each(result.visit,function(i,val){
                                if($.inArray( i, cc1 )==-1){
                                    $(".bguan p").append(
                                        '<a href="javascript:;" onclick="setValue1()" >' +
                                        val+ "</a>")
                                }else{
                                    $(".bguan p").append(
                                        '<a href="javascript:;" class="booked"  onclick="setValue1()" >' +
                                        val+ "</a>")
                                }
                            })
                        }
                    }
                // }
            },
            error: function(result){
                alert("错误");
            },
        });
    });

    var countdown = 60;
    //发送验证码
    $('.ctime').val(countdown);

    var timeInc = setInterval(function() {
        countdown = $('.ctime').val();
        if(countdown>=0 && countdown <60 && $('.telephone').val().length==11){
            // alert(111)
            settime($(".send"));
            window.clearInterval(timeInc);
        }

    },1000)

    function settime(obj) {
        if (countdown == 0) {
            $('.send').addClass('send_button');
            obj.attr("onclick","sendMobile()");//设置onclick属性
            obj.text("获取验证码");
            countdown = 60;
            return;
        } else {
            $('.send').removeClass('send_button');
            obj.removeAttr("onclick");//移除onclick属性
            obj.text("重新发送(" + countdown + ")");
            countdown--;
        }
        $('.ctime').val(countdown)
        setTimeout(function() {settime(obj) },1000);//设置定时任务，1000毫秒为1秒
    }



    function sendMobile(obj) {
        var mobile = $('.telephone').val();

        if(mobile == ""){
            layer.msg('请输入手机号',{
                icon: 2,
                title:false,
                time:5000

            })
            return false;
        }else{
            // settime($(".send"));//设置倒计时
            $.ajax({
                type: 'POST',
                url: 'sendSNS',
                data: {"mobile":mobile},
                dataType:'json',
                success: function (eee) {
                    if(eee== 1){
                        settime($(".send"));//设置倒计时
                        layer.msg('发送成功',{
                            icon: 1,
                            title:false,
                            time:5000

                        })
                        return false;
                    }
                },
            });
        }
    }

    /**
     * 预约类型选择
     * */
    $('.order_type .venue').click(function(){
        if($('.order_type .venue.select').attr('data-v') == "团队"){
            $('.visitor_num').show();
            $('.company').show();
        }else{
            $('.visitor_num').hide();
            $('.company').hide();
        }
    });

    $('.order_type .venue').click(function(){
        if($('.order_type .venue.select').attr('data-v') == "个人"){
            $('.personal').show();
        }else{
            $('.personal').hide();
        }
    });

    function visitorNum1(obj){
        if(obj<5){
            alert("团体预约请输入至少5人");
            // $('.timeList').hide();
            // $('.timeList1').hide();
        }
        if(obj<10){
            $('.explain1').val(0);
            changejj(0)
            $('.explain').hide();
            // $('.ttts').hide();
        }if(obj>=10){
            $('.explain1').val(1);
            changejj(1)
            $('.explain').show();
            // $('.ttts').show();
            $('.timeList1').hide()
        }
        if($('.explain1').val() == 1){
            if($('.third').hasClass('select')){
                // $('.timeList1').show()
            }
        }
    }


    $(".number").blur(function () {
        var num =  $('.number').val();
        if(num > 100){
            alert("预约人数不能超过100人");
            return false;
        }
    });

    $(".ge").click(function(){
        $(".type1").val(0);
        $('.arriveTime').hide()
    });
    $(".tu").click(function(){
        $(".type1").val(1);
    });

    $(".cgr").change(function () {
        // alert($(".cgr").val());
        if($(".cgr").val() >=10){
            $(".explain").css("display","block");
            // $(".explain1").css("display","block")
        }
        if($(".cgr").val() < 10  ){
            $(".explain").css("display","none");
            $(".explain1").val(0);
            var venue = $(".mb0 .select").attr("data-v");
            var day = $(".cday").val();
            var day1 = $(".bday").val();
            $.ajax({
                type: 'POST',
                url: 'runimformation',
                data: {"day":day,"venue":venue,"day1":day1,'explain':$(".explain1").val()},
                dataType:'json',
                success: function (result) {
                    $(".aguan p").find("a").remove();
                    $(".bguan p").find("a").remove();
                    $(".bguan").hide();
                    $('.guan_time').hide();
                    $('.bguan_span').hide();
                    if (result.yuyue){
                        if(result.explain == 1){
                            $.each(result.visit,function(i,val){
                                if($.inArray(val,result.yuyuea)==-1){
                                    $(".aguan p").append(
                                        '<a href="javascript:;" onclick="setValue()" >' +
                                        val+ "</a>")
                                }else{
                                    $(".aguan p").append(
                                        '<a href="javascript:;" class="booked" onclick="setValue()" >' +
                                        val+ "</a>")
                                }
                            });
                            if(result.yuyueb){
                                $('.bguan_span').show();
                                $(".bguan").css("display","block");
                                $('.guan_time').show();
                                $(".bguan").append(
                                    ' <input class="time1" name="time1" type="hidden">');
                                // var arr1=JSON.stringify(result.yuyueb);
                                // var cc1=JSON.parse(arr1);
                                $.each(result.visit,function(i,val){
                                    if($.inArray( val, result.yuyuebb)==-1){
                                        $(".bguan p").append(
                                            '<a href="javascript:;" onclick="setValue1()" >' +
                                            val+ "</a>")
                                    }else{
                                        $(".bguan p").append(
                                            '<a href="javascript:;" class="booked"  onclick="setValue1()" >' +
                                            val+ "</a>")
                                    }
                                })
                            }
                        }else{
                            var arr=JSON.stringify(result.yuyue);
                            var cc=JSON.parse(arr);
                            $.each(result.visit,function(i,val){
                                if($.inArray( i, cc )==-1){
                                    $(".aguan p").append(
                                        '<a href="javascript:;" onclick="setValue()" >' +
                                        val+ "</a>")
                                }else{
                                    $(".aguan p").append(
                                        '<a href="javascript:;" class="booked" onclick="setValue()" >' +
                                        val+ "</a>")
                                }
                            });
                            if(result.yuyueb){
                                $('.bguan_span').show();
                                $(".bguan").css("display","block");
                                $('.guan_time').show();
                                $(".bguan").append(
                                    ' <input class="time1" name="time1" type="hidden">');
                                var arr1=JSON.stringify(result.yuyueb);
                                var cc1=JSON.parse(arr1);
                                $.each(result.visit,function(i,val){
                                    if($.inArray( i, cc1 )==-1){
                                        $(".bguan p").append(
                                            '<a href="javascript:;" onclick="setValue1()" >' +
                                            val+ "</a>")
                                    }else{
                                        $(".bguan p").append(
                                            '<a href="javascript:;" class="booked"  onclick="setValue1()" >' +
                                            val+ "</a>")
                                    }
                                })
                            }
                        }

                    }
                },
                error: function(result){
                    alert("错误");
                },
            });
        }
    });


    //获取省份
    $(".province").click(function(){
        $(".city1").css("display","block");
        $(".city1").find("option").remove();
        $.ajax({
            type: 'get',
            url: '/home/user/province',
            data: {"id":$(".province").val()},
            dataType:'json',
            success: function (result) {
                $.each(result,function(i,val){
                    $(".city").append(
                        '<option  value="'+i+'">' +
                        val+ "</option>")
                });
            },
        });
    });

    //获取 城市
    $(".city").click(function(){
        $(".country1").css("display","block");
        $(".country1").find("option").remove();
        $.ajax({
            type: 'get',
            url: '/home/user/city',
            data: {"id":$(".city").val()},
            dataType:'json',
            success: function (result) {
                $.each(result,function(i,val){
                    $(".country").append(
                        '<option  value="'+i+'">' +
                        val+ "</option>")
                });
            },
        });
    });

</script>
</body>
</html>